<template>

  <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"
           style="position: relative;top: 50px;left: 50px">
    <h3 style="position: relative;left: 42px;top: 0;margin-bottom: 40px;margin-top:0px;color: #ea3200;">您好尊敬的用户</h3>
    <el-form-item label="用户名" prop="username">
      <el-input v-model="ruleForm.username"></el-input>
    </el-form-item>
    <el-form-item label="密码" prop="password">
      <el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button class="button" type="primary" @click="submitForm('ruleForm')">登录</el-button>
      <el-button @click="resetForm('ruleForm')">重置</el-button>
      <br>
      <a href="/reg">我还没注册呢。</a>
    </el-form-item>
  </el-form>

</template>
<style>
.button {
  background-color: #ea3200;
  border: none;
}
.button:hover{
  background-color: #ea7479;
}
.button:focus{
  background-color: #ea7479;
}

</style>
<script>
export default {
  data() {
    return {
      ruleForm: {
        username: '',
        password: '',
      },
      rules: {
        username: [
          {required: true, message: '请输入用户名', trigger: 'blur'},
          {min: 4, max: 18, message: '长度在 6 到 18 个字符', trigger: 'blur'},
          {pattern: /^[a-zA-Z]\w{5,17}$/, message: '必须以字母开头,只能包含字符,数字的6-18位字符。'}
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
          {pattern: /^[A-Za-z0-9]{6,12}$/, message: "必须是英文或者数字，并且长度为6-12个字符"}
        ]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
            this.$message.success("信息正确功能还没做")
            console.log("信息正确功能还没做")
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    getCode() {
      let url="http://localhost:9080/SMS/check";
      this.axios.get(url+"?phoneNum="+this.ruleForm.phoneNum).then((response) => {
        this.getCheck.getCode = response.data.data
        console.log(response)
      })
    }
  }
}
</script>

<style scoped>

</style>